/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.vsu.cs.piit.swing;

import java.awt.Component;
import java.util.List;
import java.util.Vector;
import javax.swing.AbstractCellEditor;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

/**
 *
 * @author Галчонок
 */
public class EntityCellEditor<T>  extends AbstractCellEditor
                            implements TableCellEditor {

    private JComboBox cb;
    private DefaultCellEditor editor;

    public EntityCellEditor(List<T> objects) {
        //entities = new ArrayList(objects);
        cb = new JComboBox(new Vector<T>(objects));
        editor = new DefaultCellEditor(cb);
    }

    @Override
    public Object getCellEditorValue() {
        return editor.getCellEditorValue();
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
        return editor.getTableCellEditorComponent(table, value, isSelected, row, column);
    }

}
